/*
 * Copyright 2015-2016 Tumblr, Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.tumblr.backboard.example;

import com.facebook.rebound.SpringSystem;
import com.tumblr.backboard.Actor;
import com.tumblr.backboard.Utils.View;
import com.tumblr.backboard.imitator.ToggleImitator;

/**
 * Demonstrates an view that shrinks when touched and bounces back when released.
 *
 * @author ericleong
 * @since 2021-05-07
 */
public class PressFragment extends BaseFraction {
    private static final double ACTIVE_VALUE = 0.5f;

    @Override
    public int getUiContent() {
        return ResourceTable.Layout_fragment_press;
    }

    @Override
    public void initComponent() {
        new Actor.Builder(SpringSystem.create(),
                mComponent.findComponentById(ResourceTable.Id_circle))
                .addMotion(new ToggleImitator(null, 1.0, ACTIVE_VALUE), View.SCALE_X, View.SCALE_Y)
                .build();
    }
}
